package com.example.testbroadcast.reciever;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;

import com.example.testbroadcast.db.BlackDAO;

import java.util.ArrayList;
import java.util.List;

public class OutgoingCallReceiver extends BroadcastReceiver {

    private List<String> blacknumberlist;

    public OutgoingCallReceiver() {

//            blacknumberlist = new ArrayList<>();
//            blacknumberlist.add("110");
//            blacknumberlist.add("119");
//            blacknumberlist.add("10086");


    }

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
        /*
        <intent-filter >
                <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
            </intent-filter>
         */

        Log.i("Main", "----onReceive: dianhua lail "+getResultData());
        BlackDAO dao=new BlackDAO(context);
        blacknumberlist=dao.queryAll();
        if (blacknumberlist.contains(getResultData())) {
            setResultData(null);
            Log.i("Main", "----onReceive: dianhua lail黑名单限制拨号 " );
        }



    }
}
